﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class TJ_YSFZXGModeWebForm : System.Web.UI.Page
    {
        private string reportName;
        protected void Page_Load(object sender, EventArgs e)
        {


            if (!IsPostBack)
            {
                InitPage();

            }
            else
            {
                reportName = Convert.ToString(ViewState["reportName"]);
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
            
        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 07:30:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 07:30:00");
            reportName = Request.QueryString["ReportName"];
            ViewState["reportName"] = reportName;
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {
            DateTime beginTime = Convert.ToDateTime(this.StartDate.Text);
            DateTime endTime = Convert.ToDateTime(this.EndDate.Text);
            string type = (this.Type.Value);
            //string centerID = Convert.ToString(this.Center.Text);
            //string stationID = (this.Station.Text).ToString();
            string start1 = beginTime.ToString();
            string end1 = endTime.ToString();
            //string type1 = (this.Type.Value).ToString();

            this.ReportViewer1.LocalReport.DataSources.Clear();
            //this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/TJ_YSFZXG.rdlc");
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/" + reportName);
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("startTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("endTime", end1);
            Microsoft.Reporting.WebForms.ReportParameter ty = new Microsoft.Reporting.WebForms.ReportParameter("type", type);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed, ty });
            string eventDispatchCenterID = UserOperateContext.Current.Seesion_Dispatch_SubCenterID; //2020-11-22 zch 登录人所处急救中心
            TJDAL dal = new TJDAL();
            ////this.Page.Title = "医疗急救中心业务款统计表";
            //DataTable dt = dal.Get_TJ_YSFZXG(beginTime, endTime, type);
            //this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_YSFZXG", dt));

            //this.ReportViewer1.LocalReport.Refresh();
            switch (reportName)
            {
                case "TJ_YSFZXG.rdlc":
                    this.Page.Title = "驾驶员/医生/担架员分站相关统计表";
                    DataTable dt = dal.Get_TJ_YSFZXG(beginTime, endTime, type, eventDispatchCenterID);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_YSFZXG", dt));
                    break;
                case "TJ_JSYGZXL.rdlc":
                    this.Page.Title = "驾驶员/医生/担架员工作效率统计表";
                    DataTable dt1 = dal.Get_TJ_JSYGZXL(beginTime, endTime, type, eventDispatchCenterID);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_JSYGZXL", dt1));
                    break;
                case "TJ_YFZCCQKTJB.rdlc":
                    this.Page.Title = "一线人员1分钟出车情况统计表";
                    DataTable dt2 = dal.Get_TJ_YFZCCQKTJB(beginTime, endTime, type, eventDispatchCenterID);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_YFZCCQKTJB", dt2));
                    break;
                default:
                    break;
            }
            this.ReportViewer1.LocalReport.Refresh();
        }
    }
}